//
//  AbstractBaseUpcycleViewController.m
//  XTCloud
//
//  Created by QA on 2017/12/5.
//  Copyright © 2017年 ShangHai HaoLei Software Technology Co., Ltd. All rights reserved.
//

#import "AbstractBaseUpcycleViewController.h"

@interface AbstractBaseUpcycleViewController ()

@property (nonatomic, strong) NSMutableArray *rightItems;

@end

@implementation AbstractBaseUpcycleViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.rightItems = [NSMutableArray array];
    }
    return self;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark Button Event 搜索切换

- (void)addSearchToNavigationItem
{
    //判断按钮是否绘制，若绘制，就不在绘制该按钮
    for(UIBarButtonItem *button in self.rightItems){
        if(button.tag == 1010) return;
    }
    
    //设置搜索按钮
    UIButton* righButtont= [UIButton buttonWithType:UIButtonTypeCustom];
    righButtont.frame = CGRectMake(0, 0, 36, 44);
    [righButtont setImage:[UIImage imageNamed:@"home_nav_left_serch"] forState:UIControlStateNormal];
    [righButtont addTarget:self action:@selector(searchChargeSelector:) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *mButtonItem = [[UIBarButtonItem alloc] initWithCustomView:righButtont];
    mButtonItem.tag = 1010;
    [self.rightItems addObject:mButtonItem];
    self.navigationItem.rightBarButtonItems = self.rightItems;
}

#pragma mark - UIButton Event

//实现以下方法，接收搜索事件
- (void)searchChargeSelector:(id)selector
{
    
}

@end
